package mr;

import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo04map {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        //多线程连接池，线程池
        ExecutorService executorService = Executors.newFixedThreadPool(8);
        //获取文件列表
        File file = new File("E:\\IDEJAVA\\mapreduce\\split");
        File[] files = file.listFiles();
        int flag=0;
        for (File f: files) {
            //为每一个文件启动一个线程
            MapTask mapTask = new MapTask(f, flag);
            executorService.submit(mapTask);
            flag++;
        }
        executorService.shutdown();
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }
}
